<?php
/*

Version 0.1
SEMF - Web Desiging Framework for Sport Event Managment
Copyright (C) 2006, SEMF Developers

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/
/**
	list_tables.php
	1. just list currently available tables
*/
	$type_module= $_GET['type_module'];
	$type_table = $_GET['type_table'];
	$project_home= $_GET['project_home'];
	
	$SEMF_ROOT = "../../";
	
	// Define that we are returning XML content & not to cache:
	header('Content-Type: text/xml');
	header('Cache-control: no-cache');
	
	$relative_project_dir = $SEMF_ROOT.$project_home;
$d = dir($relative_project_dir);
// Loop through all of the files:
while (false !== ($file = $d->read())) {
	// If the file is not this file, and does not start with a '.' or '~'
	// and does not end in LCK, then store it for later display:
	$relative_path=$relative_project_dir.'/'.$file;
	//echo $relative_path;
	if ( ($file{0} != '.') &&
		 ($file{0} != '~') &&
		 (substr($file, -3) != 'php') &&
		 is_dir($relative_path) )
		 {
			if($file == "store") //we ignore this..
			{
				continue;
			}
			if($file == $type_module){
				$module_name=$file;
				break;
			}
	}
}

	//echo $module_name;
	$module_xml = $SEMF_ROOT.$project_home.$module_name.'/module.xml';


//print_r($module_xml);
$table_id = 0;
if (file_exists($module_xml)) {
	$doc = new DOMDocument();
	$doc->load($module_xml);
	$table_list = $doc-> getElementsByTagName('table');

	foreach ( $table_list as $table )
	{
		$table_name = $table-> getAttribute('name');
		if($type_table == $table_name){
			echo '<option value="'.$table_name.'" selected="selected" >'.$table_name.'</option>';
		}else{
			echo '<option value="'.$table_name.'"  >'.$table_name.'</option>';
		}
		
	}
}
?>

